<style lang="less" scoped>

    .item {
        align-items: flex-start;
        align-content: flex-start;
        background: #fff;
        padding: 0.35rem 0.4rem 0.35rem 0.22rem;
        border-top: 1px solid #ebebeb;
        font-size: 0.28rem;
        color: #ABABAB;
    .title {
        font-size: 0.32rem;
        color: #272727;

    }
    .title + div{
        max-width: 60%;
    }

    }
    .item:first-child {
        border-top: 0px;
    }
</style>
<template>
    <div>
        <v-header title="商家信息">
            <div slot="left">
                <div class="back_icon"></div>
            </div>
        </v-header>
        <div class="main_allScroll" :style="{top:interactive.statusBarHeight.height}">
            <swiper :list="demo01_list" height="5rem" v-model="demo01_index"></swiper>

            <div class="main">
                <div class="item">
                        <div class="title">企业名称</div>
                        <div>{{state.name}}</div>
                </div>
                <div class="item">
                    <div class="title">企业类型</div>
                    <div>{{state.categoryCode}}</div>
                </div>
                <div class="item">
                    <div class="title">企业地址</div>
                    <div style="line-height: 0.5rem;">{{area}}</div>
                </div>
                <!--<div class="item">
                    <div class="title">企业代码</div>
                    <div>DGDGD515DGDG</div>
                </div>-->
                <div class="item">
                    <div class="title">经营者</div>
                    <div>{{user.nameHide}}</div>
                </div>
                <div class="item">
                    <div class="title">经营者电话</div>
                    <div>{{state.telephone}}</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import areaData from '../../js/json';
    import { SET_BUSINESS } from 'store/business'
    import {mapActions,mapState} from 'vuex'
    import { Swiper } from 'vux'
    export default {
        components: {
            Swiper
        },
        data() {
            return {
                loadingImg: require("../../assets/img/business.png"),
                errorImg: require("../../assets/img/business.png"),
                state:{},
                area:'',
                demo01_list: [],
                demo01_index :0
            };
        },
        activated:function(){
            this.demo01_list = []
            this.getBusinessInfo();  //获取商家详情

        },
        methods:{
            ...mapActions([SET_BUSINESS]),
            //获取商家列表
            getBusinessInfo(){
                let merchantId = this.$route.query.merchantId;
                this.$ajax.business.queryMerchant({merchantId:merchantId})
                    .then((res)=>{
                        res.body.content.forEach((v)=>{
                            if(v.merchantId == this.$route.query.merchantId){
                                this.state=v;
                            }
                        })
                        let province="",city="",district="";
                        for(let i = 0 ;i <areaData.length;i++){
                            let obj = areaData[i];
                            if(this.state.province == obj.value){
                                province= obj.name;
                            }
                            if(this.state.city == obj.value && this.state.city !==this.state.province){
                                city= obj.name;
                            }
                            if(this.state.district == obj.value){
                                district= obj.name;
                            }
                        }
                        this.area = province + city+district+  this.state.detailAddress;
                        if(this.state.mainImg){
                            this.demo01_list.push({
                                url: 'javascript:',
                                img: this.state.mainImg,
                            })
                        }
                        if(this.state.extraImg){
                            let arr = this.state.extraImg.split(',');
                            for( let i in arr){
                                this.demo01_list.push({
                                    url: 'javascript:',
                                    img: arr[i],
                                })
                            }
                        }
                    })
            }
        },
        computed: mapState({business:state=>state.business,user:state=>state.user,interactive: state => state.interactive}),

    }
</script>